//
//  visitorTableViewController.swift
//  swiftWeibo
//
//  Created by apple on 15/12/9.
//  Copyright © 2015年 张智伟. All rights reserved.
//

import UIKit

class VisitorTableViewController: UITableViewController {
    //用户登录标记
    private var userLogon = false
    //访客视图
    var visitorView: VisitorView?
    override func loadView() {
        
        userLogon ? super.loadView() : setupVisitorView()
    }
    
    //设置访客视图
    private func setupVisitorView(){
        //替换根视图
        visitorView = VisitorView()
        view = visitorView
        //添加监听方法
        visitorView?.loginButton.addTarget(self, action: "visitorViewDidLogin", forControlEvents: UIControlEvents.TouchUpInside)
        visitorView?.registerButton.addTarget(self, action: "visitorViewDidRegistor", forControlEvents: UIControlEvents.TouchUpInside)
//        view.backgroundColor = UIColor.blueColor()
    }
}

extension VisitorTableViewController {
    func visitorViewDidLogin() {
        print("登录")
    }
    func visitorViewDidRegistor() {
        print("注册")
    }
}